package com.caogt.microservice.UserInfo.controller;


import com.caogt.microservice.UserInfo.entity.UserInfo;
import com.caogt.microservice.UserInfo.service.IUserInfoService;
import com.caogt.microservice.Utils.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author caogt
 * @since 2019-05-31
 */
@RestController
@RequestMapping("/UserInfo/user-info")
@Api("用户管理")
public class UserInfoController {

    @Autowired
    private IUserInfoService userInfoService;
    @GetMapping("/save")
    @ApiModelProperty("用户信息保存")
    public ResultData save(UserInfo userInfo){
        userInfoService.save(userInfo);
        return ResultData.success();
    }
    @PostMapping("/save-batch")
    @ApiModelProperty("用户信息保存")
    public ResultData saveBatch(@RequestBody List<UserInfo> userInfo){
        userInfoService.saveBatch(userInfo);
        userInfoService.updateById(null);
        return ResultData.success();
    }
    @GetMapping("/query")
    @ApiModelProperty("用户信息列表")
    public ResultData query(){
        return ResultData.success(userInfoService.list());
    }
}
